package app.displayTree.special.sub {
	import app.displayTree.analyze.DisplayTreeAnalyzeSupport;

	import copyengine.infoTree.meta.CESAnimationEachFrameInfoMeta;
	import copyengine.infoTree.meta.CESDisplayObjectMeta;
	import copyengine.infoTree.meta.CESTileRepeatMeta;

	import flash.display.Sprite;
	import flash.geom.Matrix;
	import flash.geom.Rectangle;

	import org.as3commons.lang.StringUtils;

	public final class TileRepeatSpecialSymbol extends SpecialSymbolHandleBasic {
        public function TileRepeatSpecialSymbol() {
            super();
        }

        override protected function isCanHandleThisSpecialSymbolKey(_symbolKey:String):Boolean {
            return StringUtils.startsWithIgnoreCase(_symbolKey, "TILE_");
        }

        override protected function doGenerateSpecialSymbolMeta(_symbol:Sprite, _support:DisplayTreeAnalyzeSupport):CESDisplayObjectMeta {
            var tileRepeatMeta:CESTileRepeatMeta = new CESTileRepeatMeta();
            tileRepeatMeta.name = _symbol.name;

            var symbolRe:Rectangle = _symbol.getBounds(_symbol.parent);

            var frameInfo:CESAnimationEachFrameInfoMeta = new CESAnimationEachFrameInfoMeta();
            var frameMatrix:Matrix = new Matrix();
            frameMatrix.translate(symbolRe.left, symbolRe.top);
            frameInfo.setMatrix(frameMatrix);
            tileRepeatMeta.frameTransformMatrixArray.push(frameInfo);

            tileRepeatMeta.width = symbolRe.width;
            tileRepeatMeta.height = symbolRe.height;
            tileRepeatMeta.alpha = _symbol.alpha;

            tileRepeatMeta.textureMeta = _support.pushMcToExportAndReturnMcTextureInfo(_symbol);

            return tileRepeatMeta;

        }
    }
}
